package com.fjb.controller.product;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fjb.common.entity.HttpCode;
import com.fjb.common.entity.JsonResult;
import com.fjb.controller.base.BaseController;
import com.fjb.pojo.login.LoginUserInfo;
import com.fjb.pojo.product.vo.ProductFilesVo;
import com.fjb.pojo.user.SysUser;
import com.fjb.service.product.ProductFilesService;

/**
 * @Description:产品文件
 * @author hemiao
 * @time:2020年1月28日 下午3:40:31
 */
@Controller
@RequestMapping("/productFiles")
public class ProductFilesController extends BaseController{
	
	@Autowired
	private ProductFilesService productFilesService;
	
	/**
	 * @Description:获得文件列表
	 * @param request
	 * @param productId
	 * @return
	 * JsonResult<List<ProductFilesVo>>
	 * @exception:
	 * @author: hemiao
	 * @time:2020年1月28日 下午3:43:34
	 */
	@RequestMapping(value="/selectList")
	@ResponseBody
	public JsonResult<List<ProductFilesVo>> selectList(HttpServletRequest request,Integer productId){
		HttpCode httpCode = HttpCode.PARAM_VERIFICATION;
		if(productId==null) {
			return new JsonResult<List<ProductFilesVo>>(null, httpCode);
		}
		LoginUserInfo userInfo = getUserInfo(request);
		SysUser sysUser = userInfo.getSysUser();
		Integer mainUserId = getMainUserId(sysUser);
		List<ProductFilesVo> infoList = productFilesService.selectList(productId, mainUserId);
		return new JsonResult<List<ProductFilesVo>>(infoList, HttpCode.SUCCESS);
	}
}
